package com.hzhjhh.view.manageView.menus.storage.inReturnGoods;

import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;

import com.hzhjhh.init.dialog.Mytable;
import com.hzhjhh.view.manageView.menus.storage.InReturnGoodsDialog;
import com.hzhjhh.view.manageView.menus.storage.constant.ShowConstants;

/**
 * 菜单栏初始化-仓库-进/退货-删除按钮
 * 
 * @author 12083
 *
 */
public class DeleteBt {

	/**
	 * 按钮
	 */
	public static JButton btInit(InReturnGoodsDialog inOutTableDialog) {
		JButton delete = new JButton();
		delete.setBounds(173, 436, 81, 30);
        delete.setText("删除");
        delete.addActionListener(event -> {
        	JTable jTable1 = inOutTableDialog.getJTable1();
        	Vector vector1 = inOutTableDialog.getVector1();
        	JScrollPane jScrollPane1 = inOutTableDialog.getJScrollPane1();
        	
        	int row = jTable1.getSelectedRow();
        	if (row < 0) {
        		JOptionPane.showMessageDialog(inOutTableDialog, "没有选择删除数据，请选择数据后执行删除操作", "提示", JOptionPane.INFORMATION_MESSAGE);
        		return;
			}
            vector1.remove(row);
            jTable1 = Mytable.maketable(vector1, ShowConstants.IN_RETURN_GOODS_HEAD_NAME); //显示内容
            jScrollPane1.getViewport().add(jTable1); //把表装入容器
        });
		return delete;
	}
}
